﻿namespace Services
{
  using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using DocProcessingRepository.Interfaces;
  using Entities;
  using Exceptions;
  using ServiceInterfaces;

  public class MediaDefinitionAuditService : IMediaDefinitionAuditService
  {
    private readonly IMediaDefinitionAuditRepository auditRepository;

    public MediaDefinitionAuditService(IMediaDefinitionAuditRepository auditRepository)
    {
      this.auditRepository = auditRepository;
    }

    public List<MediaDefinitionAuditEntity> GetAudits(Int32 mediaDefinitionId)
    {
      try
      {
        return this.auditRepository.GetAudits(mediaDefinitionId);
      }
      catch (Exception e)
      {
        throw new DocProcessingException("Unable to get MediaDefinitionAudits", e);
      }
    }

    public MediaDefinitionAuditEntity AddAudit(Int32 mediaDefinitionId, String userId, MediaDefinitionAudit.MediaDefinitionAuditType auditType, DateTime auditDate, String details)
    {
      try
      {
        return this.auditRepository.AddAudit(mediaDefinitionId, userId, auditType, auditDate, details);
      }
      catch (Exception e)
      {
        throw new DocProcessingException("Unable to create MediaDefinitionAudit", e);
      }
    }
  }
}
